﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SM2TestRunner;

namespace Popups
{
    public partial class SearchSetup : Form
    {
        public static string strAction;

        public SearchSetup()
        {
            InitializeComponent();
        }

        public static DialogResult ShowSearchSetup(string straction)
        {
            SearchSetup dialog = new SearchSetup();
            strAction = straction;
            return dialog.ShowDialog();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            InputDispatcher.TEST_PARAMETER = new TestParameters();

            switch (strAction)
            {
                case "New":
                    #region
                    string strSearchKeyword_NewSearchManualEntry = tbSearchKeyword.Text.Trim();
                    string strSelectedProfileName_NewSearchManualEntry = comboBoxProfiles.SelectedValue.ToString();
                    InputDispatcher.TEST_PARAMETER.add("SearchKeyword_NewSearchManualEntry", strSearchKeyword_NewSearchManualEntry);
                    InputDispatcher.TEST_PARAMETER.add("SelectedProfileName_NewSearchManualEntry", strSelectedProfileName_NewSearchManualEntry);
                    break;
                    #endregion

                default:
                    break;
            }

            this.Close();
        }

        private void SearchSetup_Load(object sender, EventArgs e)
        {
            #region PROFILE
            comboBoxProfiles.DisplayMember = "Attribute2";
            comboBoxProfiles.ValueMember = "Attribute1";
            try
            {
                comboBoxProfiles.DataSource = Repository.ServerHardDataUtil.buildProfilesDataTable();
            }
            catch (Exception ex)
            {
                Utilities.GlobalObject.LOGGER.log("Failed to load ListBox Dashboard.CHART Utilities.GlobalInit.buildProfilesDataTable()");
                Utilities.GlobalObject.LOGGER.log(ex.ToString());
            }
            #endregion

            switch (strAction)
            {
                case "New":
                    #region
                    labelTitle.Text = "Create New Search";

                    break;
                    #endregion

                default:
                    break;
            }
        }

        private void btnDISCARD_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
